package Web2.Reginstdao;

import Web.JdbcUtils.JdbcUtils;
import org.springframework.jdbc.core.JdbcTemplate;

public class Reginstdao2 {
//对数据库查询判断用户是否存在
    public Integer Regist(String username,String password) {
        JdbcTemplate jdbcTemplate = new JdbcTemplate(JdbcUtils.getDataSource());
        //编写sql语句
        String sql="insert into user2 values (?,?,?)";
        int count = jdbcTemplate.update(sql, null, username, password);
    return count;
    }

    public Integer chek(String username) {
        JdbcTemplate jdbcTemplate = new JdbcTemplate(JdbcUtils.getDataSource());
        //编写sql语句
        String sql= "select count(*) from user2 where username=? ";
        Integer count = jdbcTemplate.queryForObject(sql, int.class, username);
        return count;
    }
}
